<template>
	<view class="lease_restitution">
		<view class="container mt20">
			<lease-order-goods :image="orderDetail.lease_goods_info.image">
				<template #name>{{ orderDetail.goods_name }}</template>
				<!-- <template #name>{{ orderDetail.goods_name }}</template> -->
				<template #specs>
					<text class="mr10">规格：租完可还/买断</text>
					<!-- <text>{{item.order_goods.goods_item_str}}{{ getPeriodsUnit(item.periods_attribute) }}</text> -->
					<text>{{orderDetail.lease_goods_item_str}}</text>
				</template>
				<template #tenancy>
					<text class="mr10">租期：</text>
					<text>{{orderDetail.lease_start_date}}至{{orderDetail.lease_end_date}}</text>
				</template>
				<template #num>
					<text class="mr10">数量：</text>
					<text>{{orderDetail.goods_num}}</text>
				</template>
			</lease-order-goods>
		</view>
		<view class="container mt40">
			<view class="pay-buy row-between buy-title">
				<text>买断价格</text>
				<text>￥{{orderDetail.lease_price}}</text>
			</view>
			<view class="pay-buy row-between">
				<text>已付租金</text>
				<text>-￥{{orderDetail.paid_rent}}</text>
			</view>
			<view class="pay-buy row-between">
				<text>已付押金</text>
				<text>-￥{{orderDetail.paid_deposit}}</text>
			</view>
			<!-- <view class="pay-buy row-between">
				<text>已冻结押金</text>
				<text>-￥{{orderDetail.lease_price}}</text>
			</view> -->
			<view class="pay-buy row-between">
				<text>逾期滞纳金</text>
				<text>+￥{{orderDetail.late_fee}}</text>
			</view>


		</view>
		<view class="card-button row-between">
			<view class="meney-all">
				共计 <text>￥</text><text>{{orderDetail.pay_amount}}</text>
			</view>
			<u-button style="flex: 1;" type="primary" shape="circle" @click="confirmReturn">确认买断</u-button>
		</view>
	</view>
</template>

<script>
	import {
		orederBuyup
	} from '@/api/lease.js'
	export default {
		data() {
			return {
				reletId: 0, //买断订单id
				orderDetail: {

				},
			}
		},

		methods: {
			// 初始化数据
			indata() {

				orederBuyup({
					action: 'info',
					id: this.reletId
				}).then(res => {
					if (res.code != 1) return;
					this.orderDetail = res.data;

				})
			},


			//确认续租
			confirmReturn() {
				uni.showLoading({
					title: '正在提交...',
					mask: true
				});
				orederBuyup({
					action: 'submit',
					id: this.reletId,
				}).then(res => {
					if (res.code == 1) {
						this.$toast({
							title: res.msg,
							icon: 'success'
						});
						const data = res.data;
						uni.hideLoading();
						//跳转支付页面
						uni.redirectTo({
							url: `/pages/payment/payment?from=${data.from}&order_id=${data.order_id}`
						})

					}

				}).catch(()=>{
					uni.hideLoading();
				})
			}
		},

		onLoad(options) {
			const id = options.id
			this.reletId = id;
		},

		onShow() {
			this.indata()
		}
	}
</script>

<style lang="scss" scoped>
	.lease_restitution {
		padding: 0 24rpx 0 24rpx;
	}

	.container {
		padding: 20rpx;
		margin-bottom: 20rpx;
		border-radius: 14rpx;
		background-color: #FFFFFF;
	}

	.uni-list-cell {
		background-color: #FFFFFF;
		padding: 32rpx 24rpx;
		border-radius: 24rpx;
		font-size: 32rpx;
		font-weight: 500;
	}


	.card-button {
		position: fixed;
		bottom: 0;
		width: 100%;
		background: #ffffff;
		padding: 30rpx;
		z-index: 1000;
		/* 确保不被其他元素覆盖 */
		left: 0;

	}



	.relet-btn:last-child {
		margin-right: 0;
	}





	.meney-all {
		color: #000000e6;
		font-size: 28rpx;
		font-style: normal;
		font-weight: 500;
		line-height: 28rpx;
		margin-right: 80rpx;


		>text:nth-child(1) {
			color: #e63333;
			font-size: 24rpx;
			margin-left: 8rpx;
		}

		>text:nth-child(2) {
			color: #e63333;
			font-size: 40rpx;
			font-style: normal;
			font-weight: 900;
			line-height: 40rpx;
		}
	}

	.pay-buy {
		color: #00000099;
		font-size: 28rpx;
		font-style: normal;
		font-weight: 500;
		line-height: 28rpx;
		margin-top: 32rpx;
	}

	.buy-title {
		color: #000000e6;
		font-size: 32rpx;
		font-style: normal;
		font-weight: 500;
		line-height: 32rpx;
		margin-top: 10px;
		margin-bottom: 2rpx;
	}
</style>